#!usr/bin/python
# -*- coding:utf-8 -*-
import unittest


class UnittestDemo(unittest.TestCase):
    def setUp(self):
        print "test begin>>>"

    def tearDown(self):
        print "test end<<<"

    def runTest(self):
        pass

    def test_fun1(self):
        print "chifan"

    def test_fun2(self):
        print "heshui"

    def create_suite(self):
        suite = unittest.TestSuite()
        suite.addTest(UnittestDemo("test_fun1"))
        suite.addTest(UnittestDemo("test_fun2"))
        return suite

    def _test_suite(self):
        """
        ud = UnittestDemo()
        ud._test_suite()
        """
        unittest_file = "./ext/cUnittest/unittest.txt"
        f = open(unittest_file, "w")
        runner = unittest.TextTestRunner(stream=f, verbosity=2)
        runner.run(self.create_suite())
        f.close()


if __name__ == '__main__':
    ud = UnittestDemo()
    ud._test_suite()
